package com.incar.chuxing.activity;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.incar.chuxing.R;
import com.incar.chuxing.base.BaseActivity;
import com.incar.chuxing.utils.Dialogs.InCarDialog;
import com.incar.chuxing.utils.MyApplication;
import com.tencent.bugly.beta.Beta;
import com.umeng.message.PushAgent;
import com.zhy.autolayout.AutoRelativeLayout;

import butterknife.BindView;
import butterknife.OnClick;

public class AboutUsActivity extends BaseActivity {

    @BindView(R.id.title_name)
    TextView titleName;
    @BindView(R.id.imageView)
    ImageView imageView;
    @BindView(R.id.about_version)
    TextView aboutVersion;
    @BindView(R.id.about_phone)
    TextView aboutPhone;
    @BindView(R.id.about_rl_phone)
    AutoRelativeLayout aboutRlPhone;
    private Context mContext = this;
    private PushAgent mPushAgent;

    @Override
    public int getLayoutId() {
        return R.layout.activity_about_us;
    }

    @Override
    public void initView() {
        titleName.setText("关于我们");
        aboutVersion.setText("当前版本:" + ((MyApplication) getApplication()).getAppVersion());
        aboutPhone.setText(((MyApplication) getApplication()).getHotLine());
        mPushAgent = PushAgent.getInstance(this);
        mPushAgent.onAppStart();
    }

    @OnClick({R.id.about_rl_phone, R.id.title_back, R.id.version_update})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.title_back:
                finish();
                break;
            case R.id.about_rl_phone:
                final InCarDialog inCarDialog2 = new InCarDialog(mContext);
                inCarDialog2.setTitle(getString(R.string.dialogTitle));
                inCarDialog2.setMessage("是否拨打客服电话" + ((MyApplication) getApplication()).getHotLine());
                inCarDialog2.setYesOnclickListener("确定", new InCarDialog.onYesOnclickListener() {
                    @Override
                    public void onYesClick() {
                        Intent intent = new Intent();
                        intent.setAction(Intent.ACTION_DIAL);
                        intent.setData(Uri.parse("tel:" + ((MyApplication) getApplication()).getHotLine()));
                        startActivity(intent);
                        inCarDialog2.dismiss();
                    }
                });
                inCarDialog2.setNoOnclickListener("取消", new InCarDialog.onNoOnclickListener() {
                    @Override
                    public void onNoClick() {
                        inCarDialog2.dismiss();
                    }
                });
                inCarDialog2.show();
                break;
            case R.id.version_update:
                Beta.checkUpgrade();
                break;
        }
    }
}
